﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace MupdfSharp
{
    public class SystemDPIHelper
    {
        static SystemDPIHelper()
        {
            using (ManagementClass mc = new ManagementClass("Win32_DesktopMonitor"))
            {
                using (ManagementObjectCollection moc = mc.GetInstances())
                {
                    int PixelsPerXLogicalInch = 0;  // dpi for x
                    int PixelsPerYLogicalInch = 0;  // dpi for y
                    foreach (ManagementObject each in moc)
                    {
                        PixelsPerXLogicalInch = int.Parse((each.Properties["PixelsPerXLogicalInch"].Value.ToString()));
                        PixelsPerYLogicalInch = int.Parse((each.Properties["PixelsPerYLogicalInch"].Value.ToString()));
                    }
                    Console.WriteLine("PixelsPerXLogicalInch:" + PixelsPerXLogicalInch.ToString());
                    Console.WriteLine("PixelsPerYLogicalInch:" + PixelsPerYLogicalInch.ToString());
                    
                    dpi_x = PixelsPerXLogicalInch;
                    dpi_y = PixelsPerYLogicalInch;
                }
            }
        }
        public static readonly int dpi_x;
        public static readonly int dpi_y;
    }
}
